/**
 * 日志接口
 * @author luguoxiang
 * @date 2021-09-07
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
import { mergeLoad, request, syncLockLoad } from '@/soar';

const baseUrl = '/system/web-log';

/**
 * 发送日志到后端，解决线上无法查看日志问题
 * @param source 来源
 * @param stack 堆栈信息
 */
export function push(source: string, stack: any): Promise<any> {
  return mergeLoad({
    name: `${baseUrl}/push`,
    params: {
      source: `PC-${source}`,
      stack,
      href: window.location.href,
    },
    loader(data: any) {
      return request.post(`${baseUrl}/push`, {
        successMsg: false,
        errorMsg: false,
        data,
      });
    },
  });
}
